package com.scaffold.commons.file;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

/**
 * 文件服务
 * @author wangjg
 *
 */
public interface FileIO {

	/**
	 * 保存输入流的数据到指定路径
	 * @param path 保存的文件路径
	 * @param in 数据输入流
	 * @throws Exception
	 */
	public void save(String path, InputStream in) throws IOException;

	/**
	 * 读取指定路径的文件数据输出到输出流
	 * @param path 将要加载的文件路径
	 * @param out 数据输出流
	 * @throws IOException
	 */
	public void load(String path, OutputStream out) throws IOException;

	/**
	 * 文件是否存在
	 * @param path
	 * @return
	 * @throws IOException
	 */
	public boolean exists(String path) throws IOException;
	
	/**
	 * 删除文件
	 * @param path
	 * @return
	 * @throws IOException
	 */
	public boolean delete(String path) throws IOException ;
	
	/**
	 * 删除文件
	 * @param path
	 * @return
	 * @throws IOException
	 */
	public long getLength(String path) throws IOException ;

	/**
	 * @param path
	 * @return
	 * @throws IOException
	 */
	InputStream getInputStream(String path) throws IOException;

	/**
	 * @param path
	 * @return
	 * @throws IOException
	 */
	OutputStream getOutputStream(String path) throws IOException;

	/**
	 * @param path
	 * @return
	 * @throws IOException
	 */
	List<String> getChildren(String path) throws IOException;

	/**
	 * @param srcPath
	 * @param destPath
	 * @return
	 */
	boolean move(String srcPath, String destPath) throws IOException;

	/**
	 * @param path
	 * @return
	 * @throws IOException
	 */
	FileDetail getFileStatus(String path) throws IOException;

}